import Cookie from 'js-cookie'
const KEY = 'userInfo'
/**
 * 保存COOKIE
 */
export const saveUserCookie = user => {
	Cookie.set(KEY, JSON.stringify(user), { expires: 7 })
}

/**
 * 获取cookie
 */
export const getUserCookie = () => {
	let userStr = Cookie.get(KEY)
	if (userStr) {
		return JSON.parse(userStr)
	}
	return null
}

/**
 * 移除cookie
 */
export const removeUserCookie = () => {
	Cookie.remove(KEY)
}
